package top.xiangqifu.springboot2.user.vo;

import lombok.Data;
import top.xiangqifu.springboot2.user.entity.TbRole;
import top.xiangqifu.springboot2.user.entity.TbUser;
import top.xiangqifu.springboot2.user.entity.TbUserInfo;


import java.io.Serializable;

@Data
public class UserInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    private TbUser tbUser;
    private TbUserInfo tbUserInfo;
    private TbRole tbRole;

    public UserInfo viewData() {
        UserInfo userInfo = new UserInfo();
        if (this.tbUser != null) {
            userInfo.setTbUser(this.tbUser.viewData());
        }
        userInfo.setTbUserInfo(this.tbUserInfo);
        userInfo.setTbRole(this.tbRole);
        return userInfo;
    }

    public UserInfo InfoRole(){
        UserInfo userInfo = new UserInfo();
        userInfo.setTbUserInfo(this.tbUserInfo);
        userInfo.setTbRole(this.tbRole);
        return userInfo;
    }
    public UserInfo queryViewData() {
        UserInfo userInfo = new UserInfo();
        if (this.tbUser != null) {
            TbUser user=new TbUser();
            user.setUid(this.tbUser.getUid());
            user.setUsername(this.tbUser.getUsername());
            userInfo.setTbUser(user);
        }
        TbUserInfo tbUserInfo=new TbUserInfo();
        tbUserInfo.setNickname(this.tbUserInfo.getNickname());
        tbUserInfo.setImg(this.tbUserInfo.getImg());
        tbUserInfo.setInfo(this.tbUserInfo.getInfo());
        userInfo.setTbUserInfo(tbUserInfo);
        return userInfo;
    }


}
